<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('修改特殊人员')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: container-css"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="white-bg">
<div class="main-content">
    <form id="form-specialPersonRegister-edit" class="form-horizontal" AUTOCOMPLETE="OFF">
        <input id="id" name="id" type="hidden" th:value="${map['id']}"/>
        <input id="pgid" name="pgid" type="hidden" th:value="${map['pgid']}"/>
        <div class="row">
            <h4 class="form-header h4">基本信息</h4>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">发薪期间：</label>
                    <div class="col-sm-8">
                        <input id="term" name="term" class="form-control datetimepicker" type="text"
                               th:value="${map['term']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>工号：</label>
                    <div class="col-sm-8">
                        <input id="badge" name="badge" class="form-control" type="text" th:value="${map['badge']}"
                               required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">姓名：</label>
                    <div class="col-sm-8">
                        <input id="name" name="name" class="form-control" type="text" th:value="${map['name']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label"><span style="color: red; ">*</span>公司：</label>
                    <div class="col-sm-8">
                        <select id="comp" name="comp" class="form-control noselect2">
                            <option th:each="company:${companys}" th:value="${company.compID}"
                                    th:text="${company.title}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">部门：</label>
                    <div class="col-sm-8">
                        <select id="depid" name="depid" class="form-control noselect2" onchange="getpgid()">
                            <option th:each="department:${departments}" th:value="${department.DepID}"
                                    th:text="${department.DepName}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">岗位：</label>
                    <div class="col-sm-8">
                        <input name="job" id="job" class="form-control" type="text" th:value="${map['job']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">发薪银行：</label>
                    <div class="col-sm-8">
                        <select class="form-control noselect2" name="bcid" id="bcid" onchange="getyhlb()"
                                th:with="type=${@dict.getType('skyPayCards')}">
                            <option value="0"></option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                    th:value="${dict.dictValue}"></option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">银行账号：</label>
                    <div class="col-sm-8">
                        <input name="bcCard" id="bcCard" class="form-control" type="text" th:value="${map['bcCard']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">银行类别：</label>
                    <div class="col-sm-8">
                        <input name="type" id="type" class="form-control" type="text" th:value="${map['type']}"
                               disabled>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">省：</label>
                    <div class="col-sm-8">
                        <input id="sf" name="sf" class="form-control" type="text" th:value="${map['sf']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">市：</label>
                    <div class="col-sm-8">
                        <input id="s" name="s" class="form-control" type="text" th:value="${map['s']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">银联号：</label>
                    <div class="col-sm-8">
                        <input name="ylh" id="ylh" class="form-control" type="text" th:value="${map['ylh']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">银行名称：</label>
                    <div class="col-sm-8">
                        <input name="yhmc" id="yhmc" class="form-control" type="text" th:value="${map['yhmc']}">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">是否同行：</label>
                    <div class="col-sm-8">
                        <select class="form-control noselect2 " id="isth" name="isth" th:value="${map['isthid']}">
                            <option value=""></option>
                            <option value="1">是</option>
                            <option value="2">否</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">是否同城：</label>
                    <div class="col-sm-8">
                        <select class="form-control noselect2 " id="istc" name="istc">
                            <option value=""></option>
                            <option value="1">是</option>
                            <option value="2">否</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<th:block th:include="include :: bootstrap-table-editable-js"/>
<th:block th:include="include :: hr-help-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<script th:inline="javascript">
    var prefix = ctx + "specialPersonRegister";

    $(function () {
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.datetimepicker',
                type: 'date'
            });
        });
        var data = [[${map}]];
        $("#isth").val(data.isthid);
        $("#istc").val(data.istcid);
        $("#bcid").val(data.bciid);
        $("#comp").val(data.comp);
        $("#depid").val(data.depid);

    });


    function submitHandler() {
        edit();
    }

    function edit() {
        if ($.validate.form()) {
            $('#type').attr("disabled",false);
            var data = $("#form-specialPersonRegister-edit").serializeArray();
            var pgid = $("#pgid").val();
            var term = $("#term").val();
            var badge = $("#badge").val();
            var name = $("#name").val();
            var comp = $("#comp").val();
            var depid = $("#depid").val();
            var job = $("#job").val();
            var bcid = $("#bcid").val();
            var bcCard = $("#bcCard").val();
            var type = $("#type").val();
            var sf = $("#sf").val();
            var s = $("#s").val();
            var ylh = $("#ylh").val();
            var yhmc = $("#yhmc").val();
            var isth = $("#isth").val();
            var istc = $("#istc").val();

            data.push({"id": "pgid", "value": pgid});
            data.push({"id": "term", "value": term});
            data.push({"id": "badge", "value": badge});
            data.push({"id": "name", "value": name});
            data.push({"id": "comp", "value": comp});
            data.push({"id": "depid", "value": depid});
            data.push({"id": "job", "value": job});
            data.push({"id": "bcid", "value": bcid});
            data.push({"id": "bcCard", "value": bcCard});
            data.push({"id": "type", "value": type});
            data.push({"id": "sf", "value": sf});
            data.push({"id": "s", "value": s});
            data.push({"id": "ylh", "value": ylh});
            data.push({"id": "yhmc", "value": yhmc});
            data.push({"id": "isth", "value": isth});
            data.push({"id": "istc", "value": istc});
            $.operate.save(prefix + "/edit", data);
        }
    }


    //根据发薪银行查找银行类别
    function getyhlb() {
        $.ajax({
            url: prefix + "/getyhlb",
            data: {
                bcid: $("#bcid").val()
            },
            type: "post",
            dataType: "text",
            success: function (data) {
                $("#type").val(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }

    //获取pgid
    function getpgid() {
        $.ajax({
            url: prefix + "/getpgid",
            data: {
                comp: $("#comp").val(),
                depid: $("#depid").val()
            },
            type: "post",
            dataType: "text",
            success: function (data) {
                $("#pgid").val(data);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }
</script>
</body>
</html>